﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DockSample.ModelForm
{
    public partial class FrmMgrProject : Form
    {
        public String projectName;
        public String projectId;


        public FrmMgrProject()
        {
            InitializeComponent();
            initView();
        }

        public void initView()
        {
            this.dataGridView1.DataSource = null;

            DataTable dt1 = new DataTable();

            MainFormDAO dbo = new MainFormDAO();
            dt1 = dbo.GetAllProject();
            if (dt1.Rows.Count > 0)
            {
                dataGridView1.DataSource = dt1;
            }


        }

        private void btnLoad_Click(object sender, EventArgs e)
        {
            this.projectId = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();

            this.Visible = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {


            this.projectId = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();

            if (MessageBox.Show("您确定要删除id为" + this.projectId+"的项目吗?", "提示",
               MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                MainFormDAO mDAO = new MainFormDAO();
                mDAO.DeleteMainFormById(projectId);
                initView();
            }
        }


    }
}
